﻿#region Includes
using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;
using Microsoft.Xna.Framework.Net;
using Microsoft.Xna.Framework.Storage;
using System.Text;
#endregion

namespace xna_game_engine.source
{
    class CScreenImageUnitFrame : CScreenElement
    {
    #region Members
        private Texture2D mBackgroundTexture;
        private BaseWizard mAttachee;
        private StatusBar mLifeBar;
        private StatusBar mPowerBar;
        private StatusBar mXpBar;
        //private Texture2d mPicture;
    #endregion

    #region Functions
        public CScreenImageUnitFrame(Vector2 pos, BaseWizard charToAttachTo)
        {
            m_Pos = pos;
            m_Type = ScreenElementTypes.UNIT_FRAME;
            mAttachee = charToAttachTo;
            mBackgroundTexture = GameGlobals.Content.Load<Texture2D>("sprites\\unit_frames\\unit_frame_bg");
            mLifeBar = new StatusBar(new Vector2(1.0f, 0.8f), Color.Red, Color.Green);
            mPowerBar = new StatusBar(new Vector2(1.0f, 0.8f), Color.DarkBlue, Color.Blue);
            mXpBar = new StatusBar(new Vector2(1.0f, 0.3f), Color.WhiteSmoke, Color.Goldenrod);
        }
        public override void Draw()
        {
            //GameSystems.Graphics.DrawImage(mBackgroundTexture, m_Pos, Color.White);
            GameSystems.Graphics.DrawImage(mBackgroundTexture, m_Pos, Color.White);
            GameSystems.Graphics.DrawImage(mAttachee.UnitFrameImage, m_Pos + new Vector2(10.0f, 5.0f), Color.White);
            mLifeBar.Draw(m_Pos + new Vector2(100.0f, 5.0f));
            mPowerBar.Draw(m_Pos + new Vector2(100.0f, 40.0f));
            mXpBar.Draw(m_Pos + new Vector2(100.0f, 70.0f));
            GameSystems.Graphics.DrawText("" + mAttachee.Name, m_Pos + new Vector2(5.0f, 80.0f), Color.Black);
            //GameSystems.Graphics.DrawText("Gold: " + mAttachee.Gold, m_Pos + new Vector2(270.0f, 80.0f), Color.Black);

            // Status test
            if (GameGlobals.ShowStatusText)
            {
                GameSystems.Graphics.DrawText("" + mAttachee.CurHealth + "/" + mAttachee.MaxHealth, m_Pos + new Vector2(200.0f, 6.0f), Color.White);
                //GameSystems.Graphics.DrawText("" + mAttachee.CurPower + "/" + mAttachee.MaxPower, m_Pos + new Vector2(200.0f, 41.0f), Color.White);
            }
        }
        public override void Init()
        {
            //m_Texture = GameGlobals.Content.Load<Texture2D>("sprites\\health_base");
            //m_Texture = GameGlobals.Content.Load<Texture2D>(m_TextureName);
            //mLifeBar.LoadContent();
            //mPowerBar.LoadContent();
            //mXpBar.LoadContent();
        }
        public override void Update(GameTime gt)
        {
            // Todo: use attachee's health / power %s
            mLifeBar.Update(gt, mAttachee.HealthPercent);
           // mPowerBar.Update(gt, mAttachee.PowerPercent);
            //mXpBar.Update(gt, mAttachee.ExpPercent);
        }
    #endregion

    #region Properties
    #endregion
    }
}
